<template>
  <div>
    <el-table
      :data="tableData"
      style="width: 100%"
      :stripe="stripe"
      border
      :size="size"
      v-loading="loading"
      @selection-change="handleSelectionChange"
      :max-height="maxHeight"
      class="myTable"
    >
      <!-- 是否支持复选 -->
      <el-table-column
        v-if="isSelection"
        width="55"
        type="selection"
        align="center"
        fixed
      />
      <el-table-column
        width="65"
        label="序号"
        type="index"
        align="center"
        fixed
      />
      <!-- 基本列 -->
      <el-table-column
        v-for="(item, index) in tableColumns"
        :prop="item.param"
        :label="item.lable"
        :key="item.id"
        :width="item.width"
        :fixed="item.fixed"
        align="center"
      >
        <template #default="scope">
          {{ scope.row[item.param] }}
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script lang="ts" setup>
import { reactive, onMounted } from "vue";
onMounted(() => {
  interior.statusData = Object.assign({}, props.statusDatasss);
});

// 自定义事件
const emit = defineEmits(["handleClick", "handleSelectionChange"]);
// 提示文本
const interior = reactive({
  opinionText: "",
  // tag 组
  statusData: [],
});

// 接受props
const props = defineProps({
  tableColumns: {
    type: Array,
    required: true,
    default: () => {
      return [];
    },
  },
  tableData: {
    type: Array,
    required: true,
    default: () => {
      return [];
    },
  },
  tableOperation: {
    type: Object,
    default: () => {
      return {};
    },
  },
  stripe: {
    type: Boolean,
    default: false,
  },
  border: {
    type: Boolean,
    default: false,
  },
  size: {
    type: String,
    default: "small",
  },
  loading: {
    type: Boolean,
    default: false,
  },
  isSelection: {
    type: Boolean,
    default: false,
  },
  maxHeight: {
    type: Number,
    default: 450,
  },
  statusData: {
    type: Array,
    default: () => {
      return [
        { statusTxt: "待审核", judge: 0, typeTag: "info" },
        { statusTxt: "审核中", judge: 1 },
        { statusTxt: "已驳回", judge: 2, typeTag: "danger" },
        { statusTxt: "已通过", judge: 999, typeTag: "success" },
      ];
    },
  },
});

// 按钮  | 类型
const handleClick = (row, type) => {
  emit("handleClick", row, type);
};
// 多选 | 改变
const handleSelectionChange = (val) => {
  emit("handleSelectionChange", val);
};
const filterTag = (value, row) => {
  return row.gender == value;
};
</script>
<style lang="scss"></style>
